﻿@namespace SwashbucklerDiary.Components
@inherits DialogComponentBase

<MMDialog MyValue="Value"
          MyValueChanged="InternalValueChanged"
          MaxWidth="420"
          Scrollable="true">
    <MCard Rounded="@("lg")">
        <MCardTitle Class="font-weight-bold">
            @(I18n.T("Tag.Select"))
            <MSpacer></MSpacer>
            <MButton Icon="true"
                     OnClick="HandleOnCancel">
                <MIcon>mdi-close</MIcon>
            </MButton>
        </MCardTitle>
        <MCardText Class="scroll-show"
                   Style="max-height:200px;">
            <MChipGroup @bind-Values="SelectedTagId"
                        Column="true"
                        Multiple="true">
                @foreach (var item in Tags)
                {
                    <MChip @key="@(item.Id.ToString())"
                           Value="@(item.Id.ToString())"
                           Filter="true"
                           Outlined="true">
                        @(item.Name)
                    </MChip>
                }
            </MChipGroup>
        </MCardText>
        <MCardActions>
            <MButton Text="true"
                     OnClick="()=>ShowAddTag = true">
                @(I18n.T("Tag.Add"))
            </MButton>
            <MSpacer></MSpacer>
            <MButton Text="true"
                     OnClick="HandleOnCancel">
                @(I18n.T("Share.Cancel"))
            </MButton>
            <MButton Text="true"
                     Color="primary"
                     OnClick="HandleOnSave">
                @(I18n.T("Share.Save"))
            </MButton>
        </MCardActions>
    </MCard>
</MMDialog>

<InputDialog @bind-Value="ShowAddTag"
@bind-Text="AddTagName"
             Title="@(I18n.T("Tag.Add"))"
             Placeholder="@(I18n.T("Tag.Placeholder"))"
             OnOK="SaveAddTag">
</InputDialog>